﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SnmpForm
{
    public partial class ucSnmpDefault : UserControl
    {
        public ucSnmpDefault()
        {
            InitializeComponent();
            InitData();
        }
        public void InitData()
        {
            textBoxUser.Text =
                Properties.Settings.Default.SnmpDefaultUser;
            textBoxPassword.Text =
                Properties.Settings.Default.SnmpDefaultPassword;
        }
        public bool Save()
        {
            //默认账户
            string strUser = textBoxUser.Text;
            if (strUser.Length > 0)
            {
                Properties.Settings.Default.SnmpDefaultUser =
                    strUser;
            }
            else
            {
                MessageBox.Show("snmp用户名不可以为空");
                return false;
            }
            //snmp密码长度至少为8位
            string strPassword = textBoxPassword.Text;
            if (strPassword.Length >= 8)
            {
                Properties.Settings.Default.SnmpDefaultPassword = 
                    strPassword;
            }
            else
            {
                MessageBox.Show("snmp密码长度至少为8");
                return false;
            }
            return true;
        }
    }
}
